ProjectBuilder::new(name, paths::root().join(name))
}
+// Generates a project layout inside our fake home dir
+pub fn project_in_home(name: &str) -> ProjectBuilder {
+ ProjectBuilder::new(name, paths::home().join(name))
+}
+
// === Helpers ===
pub fn main_file(println: &str, deps: &[&str]) -> String {
use std::fs::{self, File};
use cargotest::rustc_host;
-use cargotest::support::{project, execs, paths};
+use cargotest::support::{project, project_in_home, execs, paths};
use hamcrest::assert_that;
#[test]
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_stdout("").with_status(0));
}
+
+#[test]
+fn build_rustflags_with_home_config() {
+ // We need a config file inside the home directory
+ let home = paths::home();
+ let home_config = home.join(".cargo");
+ fs::create_dir(&home_config).unwrap();
+ File::create(&home_config.join("config")).unwrap().write_all(br#"
+ [build]
+ rustflags = ["-Cllvm-args=-x86-asm-syntax=intel"]
+ "#).unwrap();
+
+ // And we need the project to be inside the home directory
+ // so the walking process finds the home project twice.
+ let p = project_in_home("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ "#)
+ .file("src/lib.rs", "");
+ p.build();
+
+ assert_that(p.cargo("build").arg("-v"),
+ execs().with_status(0));
+}